package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.manger.dto.BannerDto;
import com.zhentao.model.common.manger.pojo.Banner;
import com.zhentao.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author 王越潇
 * @version 1.0
 * @Date 2024/9/27 11:17
 * @Type
 */
@RestController
@RequestMapping("ma/banner")
@Api(tags = "banner管理")
public class BannerController {
    @Resource
    private BannerService bannerService;
    @PostMapping("getBanner")
    @ApiOperation("banner列表")
    public ResponseResult getBanner(@RequestBody BannerDto dto){
        return bannerService.getBanner(dto);
    }
    @PostMapping("addBanner")
    @ApiOperation("添加banner")
    public ResponseResult addBanner(@RequestBody Banner banner){
        return bannerService.addBanner(banner);
    }

    @PostMapping("updateBanner")
    @ApiOperation("修改banner")
    public ResponseResult updateBanner(@RequestBody Banner banner){
        return bannerService.updateBanner(banner);
    }
    @PostMapping("deleteBanner/{id}")
    @ApiOperation("删除banner")
    public ResponseResult deleteBanner(@PathVariable("id") Integer id){
        return bannerService.deleteBanner(id);
    }
    @PostMapping("/file")
    @ApiOperation("图片url")
    public String file(MultipartFile file) throws IOException {
        return bannerService.file(file);
    }
    @GetMapping("upAndDown/{id}")
    public ResponseResult upAndDown(@PathVariable("id") Integer id){
        return bannerService.upAndDown(id);
    }
}
